/******************************************************************************
 * @brief    音频频谱显示
 *
 * Copyright (c) 2013~2020, <master_roger@sina.com>
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Chovere Logs:
 * Date           Author       Notes
 * 2013-05-04     Morro        初版
 * 2016-02-27     Morro        按模块化方式重写
 * 2020-09-20     Morro        优化排版结构以及描述
 ******************************************************************************/
#ifndef _SPECTRUM_H_
#define _SPECTRUM_H_

#include "RGB.h"

#define NPT                           512      //采样点数
#define LED_MATRIX_WIDTH              16       //点阵宽度
#define LED_MATRIX_HEIGHT             8        //点阵高度
/*颜色定义 --------------------------------------------------------------------*/
#define LED_COLOR_BLACK               {0x00, 0x00, 0x00}
#define LED_COLOR_RED                 {0xFF, 0x33, 0x00}
#define LED_COLOR_BLUE                {0x00, 0xFF, 0xFF}
#define LED_COLOR_YELLOW              {0xFF, 0xFF, 0x00}
#define LED_COLOR_PINK                {0xFF, 0x33, 0xFF}

/*柱条*/
typedef struct {
    unsigned int rise_timer;                 //上升定时器
    unsigned int fall_timer;                 //下落定时器
    int          value;
}bar_obj_t;

/*浮标*/
typedef struct {
    unsigned int hover_timer;               //悬停定时器
    unsigned int fall_timer;                //下落定时器
    int          value;
}buoy_obj_t;


/*频谱显示管理*/
typedef struct {
    unsigned int bar_rise_time;             //谱柱上升时间(ms)
    unsigned int bar_fall_time;             //谱柱下落时间(ms)
    Color_t         bar_color;                 //谱柱显示颜色

    unsigned int buoy_hover_time;           //浮标悬停时间(ms)
    unsigned int buoy_fall_time;            //浮标下落时间(ms)
    Color_t         buoy_color;                //显示颜色

    bar_obj_t    bar[LED_MATRIX_WIDTH];     //谱柱高度
    buoy_obj_t   buoy[LED_MATRIX_WIDTH];    //浮标高度

    unsigned char power[LED_MATRIX_WIDTH]; //频谱能量值
}spectrum_view_t;

#ifdef __cplusplus
extern "C" {
#endif

void spectrum_init(void);

void spectrum_process(void);

void spectrum_view_render(void);

void spectrum_config_set(spectrum_view_t *);

void spectrum_config_get(spectrum_view_t *);

#ifdef __cplusplus
}
#endif
#endif
